package com.iyundao.io.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.iyundao.io.model.SysMenu;
import org.springframework.stereotype.Repository;


@Repository
public class SysMenuSqlProvider {

    public String insertSelective(SysMenu record) {
        BEGIN();
        INSERT_INTO("sys_menu");
        
        if (record.getSid() != null) {
            VALUES("sid", "#{sid,jdbcType=CHAR}");
        }
        
        if (record.getRealName() != null) {
            VALUES("real_name", "#{realName,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuName() != null) {
            VALUES("menu_name", "#{menuName,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuUrl() != null) {
            VALUES("menu_url", "#{menuUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuType() != null) {
            VALUES("menu_type", "#{menuType,jdbcType=VARCHAR}");
        }
        
        if (record.getParentId() != null) {
            VALUES("parent_id", "#{parentId,jdbcType=CHAR}");
        }
        
        if (record.getFlag() != null) {
            VALUES("flag", "#{flag,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateDate() != null) {
            VALUES("create_date", "#{createDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateId() != null) {
            VALUES("create_id", "#{createId,jdbcType=CHAR}");
        }
        
        if (record.getOrdeBy() != null) {
            VALUES("orde_by", "#{ordeBy,jdbcType=TINYINT}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(SysMenu record) {
        BEGIN();
        UPDATE("sys_menu");
        
        if (record.getRealName() != null) {
            SET("real_name = #{realName,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuName() != null) {
            SET("menu_name = #{menuName,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuUrl() != null) {
            SET("menu_url = #{menuUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getMenuType() != null) {
            SET("menu_type = #{menuType,jdbcType=VARCHAR}");
        }
        
        if (record.getParentId() != null) {
            SET("parent_id = #{parentId,jdbcType=CHAR}");
        }
        
        if (record.getFlag() != null) {
            SET("flag = #{flag,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateDate() != null) {
            SET("create_date = #{createDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateId() != null) {
            SET("create_id = #{createId,jdbcType=CHAR}");
        }
        
        if (record.getOrdeBy() != null) {
            SET("orde_by = #{ordeBy,jdbcType=TINYINT}");
        }
        
        WHERE("sid = #{sid,jdbcType=CHAR}");
        
        return SQL();
    }
}